/*
 * DivideFunction.h
 *
 *  Created on: 28/dic/2010
 *      Author: computer
 */

#ifndef DIVIDEFUNCTION_H_
#define DIVIDEFUNCTION_H_
#include "Function.h"
#include "Integer.h"
#include "Real.h"
#include "Rational.h"
#include "Pattern.h"

class IIDivideSimplify {
public:
	TreeExpression::Rational* operator()(TreeExpression::Integer* a, TreeExpression::Integer* b) const {
		return new TreeExpression::Rational(a->getData(),b->getData());
	}
};

class FIDivideSimplify {
public:
	TreeExpression::Real* operator()(TreeExpression::Real* a, TreeExpression::Integer* b) const {
		return new TreeExpression::Real(a->getData()/b->getData());
	}
};

class IFDivideSimplify {
public:
	TreeExpression::Real* operator()(TreeExpression::Integer* a, TreeExpression::Real* b) const {
		return new TreeExpression::Real(a->getData()/b->getData());
	}
};

class FFDivideSimplify {
public:
	TreeExpression::Real* operator()(TreeExpression::Real* a, TreeExpression::Real* b) const {
		return new TreeExpression::Real(a->getData()/b->getData());
	}
};

class RRDivideSimplify {
public:
	TreeExpression::Rational* operator()(TreeExpression::Rational* a, TreeExpression::Rational* b) const {
		return new TreeExpression::Rational(a->getNumerator()*b->getDenominator(), a->getDenominator()*b->getNumerator());
	}
};

class RFDivideSimplify {
public:
	TreeExpression::Real* operator()(TreeExpression::Rational* a, TreeExpression::Real* b) const {
		return new TreeExpression::Real((a->getNumerator()/(double)a->getDenominator())/b->getData());
	}
};

class RIDivideSimplify {
public:
	TreeExpression::Rational* operator()(TreeExpression::Rational* a, TreeExpression::Integer* b) const {
		return new TreeExpression::Rational(a->getNumerator(),a->getDenominator()*b->getData());
	}
};

class IRDivideSimplify {
public:
	TreeExpression::Rational* operator()(TreeExpression::Integer* a, TreeExpression::Rational* b) const {
		return new TreeExpression::Rational(a->getData()*b->getDenominator(),b->getNumerator());
	}
};

class FRDivideSimplify {
public:
	TreeExpression::Real* operator()(TreeExpression::Real* a, TreeExpression::Rational* b) const {
		return new TreeExpression::Real(a->getData()/(b->getNumerator()/(double)b->getDenominator()));
	}
};

#endif /* DIVIDEFUNCTION_H_ */
